﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace KD.Sms.Monitor
{
    public partial class frmParameterSettings : Form
    {
        public frmParameterSettings()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="gr"></param>
        public frmParameterSettings(DataGridViewRow gr)
        {
            InitializeComponent();

            for (int i = 1; i <= 45; i++)
            {
                txtPointCount.Items.Add(i.ToString());
                if (i <= 18)
                    txtSampleWeight.Items.Add(i.ToString());
            }

            labPailName.Text = gr.Cells["Pail_Name"].Value.ToString();
            labPointCount.Text = gr.Cells["Threshold_Value"].Value.ToString();
            labSampleWeight.Text = gr.Cells["Threshold_Weight"].Value.ToString() + " kg";
            txtPointCount.SelectedIndex = txtPointCount.FindString(gr.Cells["Threshold_Value"].Value.ToString());
            txtSampleWeight.SelectedIndex = txtSampleWeight.FindString(gr.Cells["Threshold_Weight"].Value.ToString());
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tools_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
        {
            if (e.Tool.Key == "Save")
            {
                if (DAL.SqlLite.Main.Instance.DoSetPailConfig(labPailName.Text.Replace("#桶", ""), txtPointCount.Text, txtSampleWeight.Text))
                {
                    UI.MsgBox.Show(UI.MsgType.Information, "操作成功!");
                    this.Close();
                }
            }
            else if (e.Tool.Key == "Close")
            {
                this.Close();
            }
        }

        private void frmParameterSettings_Load(object sender, EventArgs e)
        {

        }
    }
}
